﻿namespace Web.Control.WWW.Files
{
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Text.RegularExpressions;
    using System.IO;
    using Lx.Web.Common.ControlsUI;
    using Lx.Web.Common.UI;
    using Model.WWW_WWW.files;
    using BLF.WWW_WWW.Files;
    using System.Collections.Generic;

    public class Tags : BaseControl
    {
        /// <summary>
        /// 目标语言
        /// </summary>
        protected string Learn = "";
        /// <summary>
        /// 使用语言
        /// </summary>
        protected string BaseL = "";
        protected Repeater repPfil;
        protected Repeater repLfil;
        protected Repeater repWTags;
        protected Repeater repATags;
        protected List<FileTagModel> wTagList;
        protected List<FileTagModel> aTagList;
        protected List<FileDocModel> pfileList;
        protected List<FileDocModel> lfileList;
        protected override void OnLoad(EventArgs e)
        {
            if (Request.Cookies["italkiLearn"] == null && Request.Cookies["italkiSpeak"] == null)
            {
                HttpCookie llCookie = new HttpCookie("italkiLearn", "all");
                HttpCookie blCookie = new HttpCookie("italkiSpeak", "all");
                Response.Cookies.Add(llCookie);
                Response.Cookies.Add(blCookie);
            }
            if (!string.IsNullOrEmpty(Request["ll"]) && Request["ll"] != "")
            {
                Learn = Request["ll"];
                HttpCookie llCookie = new HttpCookie("italkiLearn", Learn);
                Response.Cookies.Add(llCookie);
            }
            else
            {
                Learn = Request.Cookies["italkiLearn"].Value;
            }
            if (!string.IsNullOrEmpty(Request["bl"]) && Request["bl"] != "")
            {
                BaseL = Request["bl"];
                HttpCookie blCookie = new HttpCookie("italkiSpeak", BaseL);
                Response.Cookies.Add(blCookie);
            }
            else
            {
                BaseL = "all";
                HttpCookie blCookie = new HttpCookie("italkiSpeak", BaseL);
                Response.Cookies.Add(blCookie);
            }
            ArrayList outList=new ArrayList();
            wTagList = Files.GetPopularTag(Learn, BaseL, out outList);
            //标题
            if (Learn != "" && Learn.ToLower() != "all" && BaseL != "" && BaseL.ToLower() != "all")
            {
                this.DynamicTitle = GetText("SF512", new string[] { GetLanguageText(Learn), GetLanguageText(BaseL) });
                this.DynamicKeywords = GetText("SF513", new string[] { GetLanguageText(Learn), GetLanguageText(BaseL) });
                this.DynamicDescription = GetText("SF514", new string[] { GetLanguageText(Learn), GetLanguageText(BaseL) });
            }
            else
            {
                this.DynamicTitle = GetText("SF509");
                this.DynamicKeywords = GetText("SF510");
                this.DynamicDescription = GetText("SF511");
            }

            if (repWTags != null)
            {
                repWTags.DataSource = wTagList;
                repWTags.DataBind();
            }
            if (repATags != null)
            {
                repATags.DataSource = outList[0];
                repATags.DataBind();
            }
            if (repPfil != null)
            {
                repPfil.DataSource = outList[1];
                repPfil.DataBind();
            }
            if (repLfil != null)
            {
                repLfil.DataSource = outList[2];
                repLfil.DataBind();
            }            
        }
       
    }
}
